<?php
gatekeeper();
// set the title
// for distributed plugins, be sure to use elgg_echo() for internationalization
$title = elgg_echo('submana:addlistpro');
$group = get_entity($vars ['group_guid']);
$listproj_url = elgg_get_site_url() . "submana/listpro/" . $vars ['group_guid'];
elgg_push_breadcrumb("Danh sách đề tài môn học: " . $group->name, $listproj_url);
elgg_push_breadcrumb($title);

// start building the main column of the page
$content = elgg_view_title($title);

$projectlists = elgg_get_entities(array(
    'type' => "object",
    'subtype' => "projectlist",
    'container_guid' => $vars ['group_guid']
));

foreach ($projectlists as $projectlist) {
    $vars ['group_project'] = $projectlist->group_project;
    $vars ['semester'] = $projectlist->semester;
    $vars ['academic_year'] = $projectlist->academic_year;
    break;
}
if (isset ($vars ['reused'])) {
    // add form
    $content .= elgg_view_form('addprojects', null, array(
        'group_guid' => $vars ['group_guid'],
        'group_project' => $vars ['group_project'],
        'semester' => $vars ['semester'],
        'academic_year' => $vars ['academic_year'],
        'reused' => $vars ['reused'],
        'semester_reused' => $vars ['semester_reused'],
        'academic_year_reused' => $vars ['academic_year_reused'],
        'extra' => $vars ['extra'],
    ));
} else {
    $content .= elgg_view_form('addprojects', null, array(
        'group_guid' => $vars ['group_guid'],
        'group_project' => $vars ['group_project'],
        'semester' => $vars ['semester'],
        'academic_year' => $vars ['academic_year'],
    ));
}

// optionally, add the content for the sidebar
$sidebar = "";

$body = elgg_view_layout('one_sidebar', array(
    'content' => $content,
    'sidebar' => $sidebar
));

echo elgg_view_page($title, $body);
// echo $vars ['group_guid'];
?>